package com.lucifer.cloud.boot.blog.nl2sql.service;

import com.lucifer.cloud.boot.blog.mapper.ExecuteSqlMapper;
import com.zaxxer.hikari.HikariDataSource;
import jakarta.annotation.Resource;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

/**
 * @author lucifer
 * @date 2025/3/14 14:48
 */
@Slf4j
@Service
public class ExecuteSqlService implements IExecuteSqlService{

    @Resource
    private  ExecuteSqlMapper executeSqlMapper;




    @Resource
    private HikariDataSource hikariDataSource;




    @SneakyThrows
    @Override
    public List<Map<String,Object>> executeSql(String sql) {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(hikariDataSource);
        return jdbcTemplate.queryForList(sql);
        //return this.executeSqlMapper.execute(sql);
    }
}
